﻿// GetMonsterObject.cpp: 实现文件
//

#include "pch.h"
#include "ShenTuAi.h"
#include "afxdialogex.h"
#include "GetMonsterObject.h"
#include "../ShenTuApp/STInfo.h"

// GetMonsterObject 对话框

IMPLEMENT_DYNAMIC(GetMonsterObject, CDialogEx)

GetMonsterObject::GetMonsterObject(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG3, pParent)
{

}

GetMonsterObject::~GetMonsterObject()
{
}

BOOL GetMonsterObject::OnInitDialog()
{
	UpdateData();
	m_list1.SetExtendedStyle(m_list1.GetExtendedStyle()| LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
	m_list1.InsertColumn(0, L"序号", LVCFMT_LEFT, 60);
	m_list1.InsertColumn(1, L"怪物ID", LVCFMT_LEFT, 80);
	m_list1.InsertColumn(2, L"怪物名称", LVCFMT_LEFT, 200);
	m_list1.InsertColumn(3, L"坐标", LVCFMT_LEFT, 100);
	m_list1.InsertColumn(4, L"内存地址", LVCFMT_LEFT, 100);
	m_list1.InsertColumn(5, L"血量", LVCFMT_LEFT, 100);
	InitSTInfo();
	return 0;
}

void GetMonsterObject::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, m_list1);
	DDX_Control(pDX, IDOK, m_check1);
}


BEGIN_MESSAGE_MAP(GetMonsterObject, CDialogEx)
	ON_BN_CLICKED(IDOK, &GetMonsterObject::OnBnClickedOk)
	ON_WM_MOVE()
	ON_WM_MOVING()
	ON_WM_SIZE()
END_MESSAGE_MAP()


// GetMonsterObject 消息处理程序


void GetMonsterObject::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	//CDialogEx::OnOK();
	auto monsterlist = CMainScene::Get()->GetAllObjPos();
	int count = 1;
	std::wstring content;
	m_list1.DeleteAllItems();
	for (auto monster : monsterlist) {
		auto item = m_list1.InsertItem(0, std::to_wstring(count).c_str());
		m_list1.SetItemText(item, 1, std::to_wstring(monster.info.gtypeid).c_str());//怪物ID
		m_list1.SetItemText(item, 2, Encoder::string2wstring(monster.monsterName).c_str());//怪物名称
		std::wstring wstrpos = std::to_wstring(monster.info.pos.x) + L":" + std::to_wstring(monster.info.pos.y);
		m_list1.SetItemText(item, 3, wstrpos.c_str());//怪物坐标
		m_list1.SetItemText(item, 4, std::to_wstring(monster.point).c_str());//内存地址
		auto wstrbolld = std::to_wstring(monster.blood.blood) + L"/" + std::to_wstring(monster.blood.total);
		m_list1.SetItemText(item, 5, wstrbolld.c_str());//血量
		count++;
	}
}


void GetMonsterObject::OnMove(int x, int y)
{
	CDialogEx::OnMove(x, y);

	// TODO: 在此处添加消息处理程序代码
}


void GetMonsterObject::OnMoving(UINT fwSide, LPRECT pRect)
{
	CDialogEx::OnMoving(fwSide, pRect);

	// TODO: 在此处添加消息处理程序代码
}


void GetMonsterObject::OnSize(UINT nType, int cx, int cy)
{
	CDialogEx::OnSize(nType, cx, cy);
	CRect rs;
	GetClientRect(&rs);
	rs.top += 4;
	rs.bottom -= 40;
	rs.left += 4;
	rs.right -= 4;
	m_list1.MoveWindow(&rs);
	rs.top = rs.bottom + 10;
	rs.bottom = rs.bottom + 40;
	rs.left += 100;
	rs.right = rs.left + 100;
	m_check1.MoveWindow(&rs);
	// TODO: 在此处添加消息处理程序代码
}
